package cn.micai.base.concurrent;

/**
 * @Auther: zhaoxinguo
 * @Date: 2018/7/5 16:40
 * @Description:
 */
public final class MyCounter {

    private long value = 0;

    public synchronized long getValue() {
        return value;
    }

    public synchronized long increment() {
        if (value == Long.MAX_VALUE) {
            throw new IllegalStateException("counter overflow");
        }
        return ++value;
    }

}
